import Konva from 'konva';
import { AnswersID, StuID } from '..';

export interface IImageState {
  stuID: StuID;
  images: ImageType;
}
/**上传图像 */
export type ReqImageUpload = { file_name: string; file_content: string };

/** 图像管理信息*/
export type ImageInfo = {
  /**原始图像 */
  baseUrl: string;
  /**批改后图像地址 */
  imgUrl?: string;
  id?: AnswersID;
  /**blobdata 未来备用 */
  originalImg?: Blob;
  currectImg?: Blob;
  thumbnailData?: Blob;
};

/** 图像类型*/
export type ImageType = Array<ImageInfo>;

export type ZoomOperation = {
  center: [number, number];
  ratio: number;
  imageWigthHeight?: [number, number];
};
export enum ECurrentOperation {
  /** 无状态*/
  none = 0,
  /** 回退*/
  backspacing = 1,
  /** 刷子*/
  brush = 2,
  /** 打分*/
  mark = 3,
  /** 文本*/
  text = 4,
  /** 旋转*/
  rotate = 5,
  /** 旋转*/
  chartlet = 6,
  /** 备课*/
  prepare = 7,
  /** 答案*/
  answers = 8
}

// /**生成对象 */
// getInstance: (state: IImageState, domId: string) => ImageToolManage
export interface IImageToolManage {
  /** dom标签 */
  dom: HTMLDivElement;
  /**所有layers 对象 */
  layers: Array<Konva.Shape | Konva.Layer>;
  /**konva */
  stage: Konva.Stage;
  /**当前激活的对象 */
  activeShape: Konva.Shape | null;
  /**当前工具操作*/
  currentOperation: ECurrentOperation;
  /**图像暂存*/
  state: ImageInfo;
  /**图像缩放 */
  zoom: ZoomOperation;
  /** 回退 */
  backspacing: () => void;
  /** 画笔 涂鸦 */
  brush: () => void;

  /** 旋转 */
  rotate: () => void;
  /** 贴图 */
  chartlet: () => void;
  /** 文字 */
  setText: () => void;
  /** 回归按钮状态*/
  flyback: () => void;
  /** 备课 */
  prepare: () => void;
  /**打分 */
  mark: () => void;
  /** 答案 */
  answers: () => void;
}
